﻿
Public Class MysqlDbInfo
    Private lconnectiontimeout As Integer
    Private lserverversion As String
    Private ldatabase As String
    Private ladress As String
    Private ltables As New ArrayList


    Public Property ServerAdress As String
        Get
            Return ladress
        End Get
        Set(ByVal value As String)
            ladress = value
        End Set
    End Property

    Public Property ConnectionTimeout As Integer
        Get
            Return lconnectiontimeout
        End Get
        Set(ByVal value As Integer)
            lconnectiontimeout = value
        End Set
    End Property

    Public Property Database As String
        Get
            Return ldatabase
        End Get
        Set(ByVal value As String)
            ldatabase = value
        End Set
    End Property

    Public Property ServerVersion As String
        Get
            Return lserverversion
        End Get
        Set(ByVal value As String)
            lserverversion = value
        End Set
    End Property

    Public Property Tables As ewinsync.MysqlTableInfo()
        Get
            Return ltables.ToArray
        End Get
        Set(ByVal value As ewinsync.MysqlTableInfo())
            ltables.AddRange(value)
        End Set
    End Property
    Public Function Table(ByVal tablename As String) As ewinsync.MysqlTableInfo
        Return getTable(tablename)
    End Function
    Private Function getTable(ByVal tablename As String) As ewinsync.MysqlTableInfo
        For Each r As MysqlTableInfo In ltables
            If (r.TableName = tablename) Then Return r
        Next
        Return Nothing
    End Function
    Public Sub addTable(ByRef table As MysqlTableInfo)
        Dim tt As MysqlTableInfo = getTable(table.TableName)
        If (Not IsNothing(tt)) Then
            ltables.Remove(tt)

        End If
        ltables.Add(table)
    End Sub

    Public Function DbInfoToString() As String
        Return ""
    End Function

    Public Function DbInfoToXML() As String
        Return ""
    End Function

    Public Function DbInfoToRTF() As String
        Dim cm As String = "MySql Databaser Server v." + ServerVersion
        cm = cm + vbCrLf + "Adress: " + ServerAdress
        cm = cm + vbCrLf + "Tables" + vbCrLf
        For Each tb As MysqlTableInfo In ltables
            cm = cm + vbTab + tb.TableName + " (" + tb.ColumnsNumbers.ToString + " Total Rows )" + vbCrLf
            cm = cm + vbTab + vbTab + "Columns" + vbCrLf
            cm = cm + tb.getcolumnAsString + vbCrLf
        Next
        Return cm
    End Function

    Public Sub loadInfo()

    End Sub




End Class
